<?php

use console\db\Migration;
use yii\db\Query;

/**
 * 圈子动态统计信息转移
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class m300020_000009_t_sns_dynamic_stats extends Migration {

    /**
     * @inheritdoc
     */
    public $tableName = '{{%sns_dynamic_stats}}';

    /**
     * @inheritdoc
     */
    public function safeUp() {
        $columns = [
            'dynamic_id' => 'id',
            'created_at',
            'updated_at',
        ];
        $query = (new Query())->from('{{%sns_dynamic}}')->select($columns);
        $this->insert($this->tableName, $query);
    }

    /**
     * @inheritdoc
     */
    public function safeDown() {
        $this->truncateTable($this->tableName);
    }

}
